package com.duyutian.config;

import com.duyutian.domain.Loger;
import com.duyutian.util.RedisTools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

/**
 * Created by dyt on 2018/10/18.
 */
@Component
@Configurable
@EnableScheduling
public class TaskConfig {
    @Autowired
    private RedisTools redisTools;
    @Scheduled(cron = "0 3 0 * * ?") // 每天00点的时候会清除
    public void goWork() throws Exception {
        //重置访客记录
        redisTools.set("logs",new ArrayList<Loger>());
    }
}
